<?php
/**
 * Template Name: Listings - Signature - Listings
 * Description: The listings page for Signature Listings
 *
 * @package ManterRealty
 * 
 */

get_header(); ?>
		
        <div class="listings_wrap signature_listings_wrap">
        	<?php if ( have_posts() ) : ?>
            	<?php while ( have_posts() ) : the_post(); ?>
                	<h1><?php the_title(); ?></h1>
					<?php 
					$signaturelistings = url_to_postid($root.'/listings/signature-listings');
					$pages = get_pages('child_of='.$signaturelistings.'&parent='.$signaturelistings.'&sort_column=post_date&sort_order=asc&number=3');
					
					foreach($pages as $page)
					{
						// Signature Listings Page URL
						$link = get_permalink($page->ID); 
						
						// Signature Listing Status
						$vals = get_post_custom_values('status',$page->ID);
						$status = $vals[0];
						
						// Signature Listing Teaser Image
						$vals = get_post_custom_values('teaser_image',$page->ID);
						$teaserImageArray = wp_get_attachment_image_src($vals[0], 'full');
						$teaserImage = $teaserImageArray[0];
						
						// Signature Listing Price
						$vals = get_post_custom_values('price',$page->ID);
						$price = $vals[0];
						
						// Signature Listing MLS
						$vals = get_post_custom_values('mls',$page->ID);
						$mls = $vals[0];
						
						// Signature Listing Sq. Feet
						$vals = get_post_custom_values('square_feet',$page->ID);
						$sqft= $vals[0];
						
						// Signature Listing Bedrooms
						$vals = get_post_custom_values('number_of_bedrooms',$page->ID);
						$numbed = $vals[0];
						
						// Signature Listing Bathrooms
						$vals = get_post_custom_values('number_of_bathrooms',$page->ID);
						$numbath = $vals[0];
						
						// Signature Listing Acres
						$vals = get_post_custom_values('number_of_acres',$page->ID);
						$acres = $vals[0];
						
					?>
                        
                        <div class="sig_list_item_wrap">
                        	<div class="sig_list_item_pad">
                            	<div class="sig_list_item_head">
                                	<h2 class="title">
                                    	<?php echo('<a href="'.$link.'" title="View Listing">'.$page->post_title.'</a>'); ?>
                                    </h2>
                                    <div class="status_wrap">
                                        <div class="status <?php echo($status); ?>">
                                            <?php echo('<a href="'.$link.'">'.$status.'</a>'); ?>
                                        </div>
                                    </div>
                                </div>
                                <div class="sig_list_item_content clearfix">
                                	<div class="sig_list_item_img">
                                    	<?php //echo(the_field('teaser_image')); ?>
                                    	<?php echo('<a href="'.$link.'" title="'.$page->post_title.'"><img src="'.$teaserImage.'" /></a>'); ?>
                                    </div>
                                    <div class="sig_list_item_data">
                                    	<ul>
                                        	<li>
                                            	<span class="sig_data_label">Price:</span>
                                                <span class="sig_data"><?php echo($price); ?></span>
                                            </li>
                                            <li>
                                            	<span class="sig_data_label">MLS#:</span>
                                                <span class="sig_data"><?php echo($mls); ?></span>
                                            </li>
                                            <li>
                                            	<span class="sig_data_label">Sq. Feet:</span>
                                                <span class="sig_data"><?php echo($sqft); ?></span>
                                            </li>
                                            <li>
                                            	<span class="sig_data_label">Bedrooms:</span>
                                                <span class="sig_data"><?php echo($numbed); ?></span>
                                            </li>
                                            <li>
                                            	<span class="sig_data_label">Bathrooms:</span>
                                                <span class="sig_data"><?php echo($numbath); ?></span>
                                            </li>
                                            <li>
                                            	<span class="sig_data_label">Acres:</span>
                                                <span class="sig_data"><?php echo($acres); ?></span>
                                            </li>
                                        </ul>
                                    </div>
                                </div>
                            </div>
                        </div>
                       
					 <?php } ?>
					

				<?php endwhile; ?>
             <?php endif; ?>
             <?php
				global $wp_query;
				
				$big = 999999999; // need an unlikely integer
				
				echo paginate_links( array(
					'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
					'format' => '?paged=%#%',
					'current' => max( 1, get_query_var('paged') ),
					'total' => $wp_query->max_num_pages
				) );
			?>
        </div>

<?php get_footer(); ?>